#include "entitycontainer.h"

namespace Demo {

EntityContainer::EntityContainer()
{
}

EntityContainer::~EntityContainer()
{
}

void EntityContainer::addEntity(const IEntityPtr &entity)
{
    for (auto item = begin(); item != end(); ++item)
    {
        if (*item == entity)
        {
            myDebug() << "Added entity twice in Demo::EntityContainer::addEntity()\n";
            return;
        }
    }
    _entities.push_back(entity);
}

void EntityContainer::removeEntity(const IEntityPtr &entity)
{
    for (auto item = begin(); item != end(); ++item)
    {
        if (*item == entity)
        {
            _entities.erase(item);
        }
    }
}

EntityContainer::ConstIterator EntityContainer::begin() const
{
    return _entities.begin();
}

EntityContainer::ConstIterator EntityContainer::end() const
{
    return _entities.end();
}

EntityContainer::Iterator EntityContainer::begin()
{
    return _entities.begin();
}

EntityContainer::Iterator EntityContainer::end()
{
    return _entities.end();
}

} // namespace Demo
